class MoveClipSpriteSheet extends egret.Bitmap {
    private textureName: string;
    private mcDataName: string;
    private mcData : any;
    private framefNum: number;
    private spriteSheet: egret.SpriteSheet;
    private currFrame: number = 0;
    private frameW: number = 0;
    private frameH: number = 0;
    private m_currentTime: number = 0;
    private m_moveMent: any;
    private m_frames: any;
    private mloop: boolean = true;
 
    public constructor(resName: string, frameCount: number, loop: boolean) {
        super()
        this.textureName = resName;
        this.framefNum = frameCount;
        this.mloop = loop;

        this.init();
    }
 
    private init(): void {
        //创建 SpriteSheet 对象
        this.spriteSheet = RES.getRes(this.textureName);
        /*this.mcData = RES.getRes(this.mcDataName);
        
        let mc = this.mcData.mc.mc_niao;
        for (var i = 0; i < mc.labels.length; i++) {
            let label = mc.labels[i];
        }*/
    }

    public gotoAndPlay(frameCount: number): void{
        this.currFrame = frameCount;
        this.draw();
    }
    public reset(): void{
         this.m_currentTime = 0;
    }
    public hasdraw(): boolean{
        return this.texture != null;
    }
 
    private draw(): void {
        //console.log("this.currFrame :" + this.currFrame )
        var key: string = this.textureName + this.currFrame;
        this.texture = this.spriteSheet.getTexture(key)
        if(!this.texture) {
            this.texture = this.spriteSheet.createTexture(key,this.frameW * this.currFrame,0,this.frameW,this.frameH);
        }
    }
 
 
    public render(dtime: number): void {
        this.m_currentTime += dtime;
        var tF: number = Math.floor(this.m_currentTime / 120);
        //console.log("tf:"+tF)
        if(tF != this.currFrame) {
            this.currFrame = tF;
 
            
            if(this.currFrame >= this.framefNum) {
                //console.log("moveClip over!");
                if(this.mloop)
                {
                    this.currFrame = 0;
                    this.m_currentTime = 0;
                }
                else
                {
                    this.currFrame = this.framefNum-1;
                }
            }
 
            this.draw();
        }
    }
 
 
}